package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.ProjectPlanRequestDto;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.ContractVo;
import com.zzyl.vo.NursingPlanVo;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/nursing_project")
@Api(tags = "护理项目管理")
public class NursingProjectController {

    @Autowired
    private NursingProjectService nursingProjectService;
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "护理姓名", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "状态", required = false, dataType = "int", paramType = "query")
    })
    @GetMapping
    @ApiOperation("分页查询护理项目列表")
    public ResponseResult<PageResponse<NursingProjectVo>> selectByPage(
            Integer pageNum,
            Integer pageSize,
            String name,
            Integer status
    ){
        PageResponse<NursingProjectVo> nursingProjectPageInfo = nursingProjectService.getByPage(name, status, pageNum, pageSize);
        return ResponseResult.success(nursingProjectPageInfo);
    }
    /**
     * 新增
     */
    @PostMapping
    @ApiOperation("新增护理项目")
    public ResponseResult addNursingProject(NursingProjectVo nursingProjectVo){
        nursingProjectService.addNursingProject(nursingProjectVo);
        return ResponseResult.success();
    }

    /**
     * 1.3 根据id查询护理
     * - 接口地址:/nursing_project/{id}
     * - 请求方式:GET
     * - 请求参数:
     */
    @GetMapping("/{id}")
    @ApiOperation("根据id查询护理")
    public ResponseResult<NursingProjectVo> getById(@PathVariable Long id){
        NursingProjectVo nursingProjectVo = nursingProjectService.getById(id);
        return ResponseResult.success(nursingProjectVo);
    }
    /**
     * 1.4 编辑
     * - 接口地址:/nursing_project
     * - 请求方式:PUT
     */
    @PutMapping
    @ApiOperation("编辑")
    public ResponseResult update(@RequestBody NursingProjectVo nursingProjectVo){
        nursingProjectService.updateNursingProject(nursingProjectVo);
        return ResponseResult.success();
    }

    /**
     * - 接口地址:/nursing_project/{id}/status/{status}
     * - 请求方式:PUT
     */
    @PutMapping("/{id}/status/{status}")
    @ApiOperation("启用禁用")
    public ResponseResult ooo(@PathVariable long id,@PathVariable Integer status){
        nursingProjectService.ooo(id,status);
        return ResponseResult.success();
    }

    /**
     * 1.6 删除
     * - 接口地址:/nursing_project/{id}
     * - 请求方式:DELETE
     */
    @DeleteMapping("/{id}")
    @ApiOperation("删除")
    public ResponseResult deleteById(@PathVariable Long id){
        nursingProjectService.deleteById(id);
        return ResponseResult.success();
    }

    /**
     * - 接口地址:/nursing_project/all
     * - 请求方式:GET
     * - 请求参数:无
     */
    @GetMapping("/all")
    @ApiOperation("查询所有护理项目")
    public ResponseResult<NursingProjectVo> getAll(){
        return ResponseResult.success(nursingProjectService.getAll());
    }

//    /**
//     * 2.1 查询所有护理计划
//     * 接口地址:/nursing/plan
//     * 请求方式:GET
//     * 请求参数:无
//     */
//    @GetMapping("/plan")
//    @ApiOperation("查询所有护理计划")
//    public ResponseResult<NursingPlanVo> getAllPlan(){
//        return ResponseResult.success(nursingProjectService.getAllPlan());
//    }
//
//    /**
//     * 2.2 新增
//     * 接口地址:/nursing/plan
//     * 请求方式:POST
//     * 请求示例:
//     */
//    @PostMapping("/plan")
//    @ApiOperation("新增")
//    public ResponseResult addNursingPlan(ProjectPlanRequestDto projectPlanRequestDto){
//        nursingProjectService.addNursingPlan(projectPlanRequestDto);
//        return ResponseResult.success();
//    }
//
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "int", paramType = "query"),
//            @ApiImplicitParam(name = "pageSize", value = "每页数量", required = true, dataType = "int", paramType = "query"),
//            @ApiImplicitParam(name = "name", value = "护理姓名", required = false, dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "status", value = "状态", required = false, dataType = "int", paramType = "query")
//    })
//    @GetMapping
//    @ApiOperation("护理计划条件分页查询")
//    public ResponseResult<PageResponse<NursingPlanVo>> selectByPagePlan(
//            Integer pageNum,
//            Integer pageSize,
//            String name,
//            Integer status
//    ){
//        PageResponse<NursingPlanVo> ooo = nursingProjectService.getByPagePlan(name, status, pageNum, pageSize);
//        return ResponseResult.success(ooo);
//    }
}
